package edu.iiitb.studentinfo.action;

import java.util.ArrayList;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import edu.iiitb.studentinfo.model.Announcement;
import edu.iiitb.studentinfo.model.Student;
import edu.iiitb.studentinfo.service.StudentService;

public class ShowDetailsAction extends ActionSupport{
	
	private static final long serialVersionUID = 1L;
	private int studentId;
	private Student studentBean;
	private ArrayList<Announcement> announcements;
	
	
	public int getStudentId() {
		return studentId;
	}
	public void setStudentId(int studentId) {
		this.studentId = studentId;
	}
	public Student getStudentBean() {
		return studentBean;
	}
	public void setStudentBean(Student studentBean) {
		this.studentBean = studentBean;
	}
	public ArrayList<Announcement> getAnnouncements() {
		return announcements;
	}
	public void setAnnouncements(ArrayList<Announcement> announcements) {
		this.announcements = announcements;
	}
	
	public String execute() {
		
		StudentService studentService = new StudentService();
		studentBean = studentService.getStudentInfo(studentId);
		studentBean.setStudentId(this.getStudentId());
		this.announcements = studentService.getAnnouncements(this.studentBean.getSpecializationId());
		return "success";
	}
}
